<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    function load(url){
        var p=new Promise(function(resolve,reject){
          var img=new Image()
          img.src=url
          img.onload=function(){
              resolve(img)
          }
        });
        return p;
    }
    
    function loadlocal(url){
        var p=new Promise(function(resolve,reject){
            setTimeout(function(){
                var img=new Image()
                img.src=url
                img.onload=function(){
                    resolve(img)
                }
            },1000)
        });
        return p;
    }

    Promise.race([load("http://www.ruanyifeng.com/blogimg/asset/2014/bg2014100801.jpg"),loadlocal("girlbig1.jpg")]).then(function(img){
        console.log(img)
        document.body.appendChild(img)
    })
    </script>
</body>
</html>